package by.grsu.perovskij.page;

import java.util.List;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.spring.injection.annot.SpringBean;

import by.grsu.perovskij.dao.TicketRequestDao;
import by.grsu.perovskij.entity.TicketRequest;

@SuppressWarnings("serial")
public class ListTicketRequestsPage extends BasePage {
	
	@SpringBean
	private TicketRequestDao ticketRequestDao;

	public ListTicketRequestsPage() {
		super();

		final List<TicketRequest> ticketRequests = ticketRequestDao.findAll();

		add(new ListView<TicketRequest>("list", ticketRequests) {
			@Override
			protected void populateItem(final ListItem<TicketRequest> item) {
				final TicketRequest request = item.getModelObject();
				item.add(new Label("passenger", request.getPassenger()
						.getSecondName()));
				item.add(new Label("route", request.getScheduleRecord()
						.getName()));
				/*
				 * item.add(new Link<TicketRequest>("editLink",new
				 * Model<TicketRequest>(request)){
				 * 
				 * @Override public void onClick(){ setResponsePage(new
				 * EditTicketRequest(request)); } });
				 */
			}
		});
		/*
		 * add(new Link<TicketRequest>("createLink", new
		 * Model<TicketRequest>(new TicketRequest())) {
		 * 
		 * @Override public void onClick() { setResponsePage(new
		 * EditTicketRequest(getModelObject())); } });
		 */
	}

}
